package org.blogwu.learn.designpattern.chapter8.hungry;

import java.io.*;

public class Test {

    public static void main(String[] args) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException {

        HungrySingleton hungrySingleton = HungrySingleton.getInstance();
        System.out.println(hungrySingleton);
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("/Users/zsyubo/Documents/temp/xx.obj"));
        objectOutputStream.writeObject(hungrySingleton);


        File file = new File("/Users/zsyubo/Documents/temp/xx.obj");
        ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(file));
        HungrySingleton hungrySingleton2 = (HungrySingleton) objectInputStream.readObject();
        System.out.println(hungrySingleton2);

    }
}
